import 'package:flutter/material.dart';
import 'package:flutter_blog/compoments/blog/index.dart';
import 'package:flutter_blog/compoments/home/index.dart';
import 'package:flutter_blog/compoments/travel/index.dart';
import 'package:flutter_blog/compoments/proflie/index.dart';

class Home extends StatefulWidget {
  Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  final List<Widget> _childrenPages = [
    HomeIindexPage(),
    BlogIndexPage(),
    TravelIndexPage(),
    ProfileIndexPage()
  ];
  //记录点击对象
  int _currentIndex = 0;

  List<BottomNavigationBarItem> _itemImgList = [
    new BottomNavigationBarItem(
        icon: Icon(
          Icons.ac_unit,
          size: 20,
        ),
        title: Text('首页')),
    new BottomNavigationBarItem(
        icon: Icon(Icons.access_alarm), title: Text('博客')),
    new BottomNavigationBarItem(icon: Icon(Icons.ac_unit), title: Text('旅程')),
    new BottomNavigationBarItem(icon: Icon(Icons.ac_unit), title: Text('简介')),
  ];
  onTabTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('widget.title'),
      // ),
      body: _childrenPages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: _itemImgList,
        onTap: onTabTapped,
        currentIndex: _currentIndex,
      ),
    );
  }
}
